<template>
  <div class="newinfo-container">
    <!-- 大标题 -->
    <h3 class="title">{{ newsInfo.title}}</h3>

    <!-- 子标题 -->
    <p class="subtitle">
      <span>发表时间：{{newsInfo.dateAdd | dataFormat}}</span>
      <span>点击：{{newsInfo.id}}次</span>
    </p>

    <hr />

    <!-- 内容区域 -->
    <div class="content" v-html="newsInfo.content"></div>

    <hr />

    <!-- 评论区域 -->
    <comment-unit :id="this.id"></comment-unit>
  </div>
</template>

<script>
import { Toast } from "mint-ui";
import comment from "../subcomponents/comment.vue";

export default {
  data() {
    return {
      id: this.$route.params.author,
      newsInfo: {}
    };
  },

  created() {
    this.getNewsInfo();
  },

  methods: {
    getNewsInfo() {
      this.$http
        .get("https://api.it120.cc/pp/cms/news/detail?id=" + this.id)
        .then(result => {
          this.newsInfo = result.body.data;
        });
    },

    jump() {
      window.location.href = this.newsInfo[0].url;
    }
  },

  components: {
    "comment-unit": comment
  }
};
</script>

<style lang="scss" scoped>
.newinfo-container {
  padding: 0 4px;
  .title {
    font-size: 16px;
    text-align: center;
    margin: 15px 0;
    color: red;
  }
  .subtitle {
    font-size: 13px;
    color: #226aff;
    display: flex;
    justify-content: space-between;
  }
  .content {
    width: 100%;
  }
}
</style>